<!--
 * @Author: your name
 * @Date: 2022-03-15 11:12:29
 * @LastEditTime: 2022-03-15 12:41:26
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\前端this指向问题普通函数220315.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>前端this指向问题普通函数apply</title>
</head>
<body>
  <script>
    //口诀 谁调用就会指向谁 这边是普通函数 直接报错this.fang is not a function
    var name="geyao"
      var fangfang = {
        name : "fangfang",

        fang: function () {
            console.log(this.name)
        },

        fun: function () {
            setTimeout( function () {
                this.fang()
            }.apply(this,fangfang),100);
        }

    };
    fangfang.fun()//fang


  </script>
  
</body>
</html>